package org.tony.common.ui;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.TexturePaint;
import java.awt.image.BufferedImage;


public class CommUiUtil {

	/**
	 * 创建间渐变画笔
	 * @param image
	 * @return
	 */
	public static TexturePaint createTexturePaint(Image image) {
	    int imageWidth = image.getWidth(null);
	    int imageHeight = image.getHeight(null);
	    BufferedImage bi = new BufferedImage(imageWidth, imageHeight, 2);
	    Graphics2D g2d = bi.createGraphics();
	    g2d.drawImage(image, 0, 0, null);
	    g2d.dispose();
	    return new TexturePaint(bi, new Rectangle(0, 0, imageWidth, imageHeight));
	  }
}
